home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
p_man
/
cat3
/
f90
/
index.z
/
index
Wrap
Text File
|
1998-10-30
|
4KB
|
93 lines
INDEX(3I) Last changed: 1-6-98
NNAAMMEE
IINNDDEEXX - Determines the starting location of a character substring in a
string
SSYYNNOOPPSSIISS
IINNDDEEXX (([SSTTRRIINNGG==]_s_t_r_i_n_g,, [SSUUBBSSTTRRIINNGG==]_s_u_b_s_t_r_i_n_g [,,[BBAACCKK==]_b_a_c_k]))
IIMMPPLLEEMMEENNTTAATTIIOONN
UNICOS, UNICOS/mk, and IRIX systems
SSTTAANNDDAARRDDSS
Fortran 90
DDEESSCCRRIIPPTTIIOONN
The IINNDDEEXX intrinsic function returns the starting position of a
substring within a string from either the right or left end of the
string. It accepts the following arguments:
_s_t_r_i_n_g Must be of type character.
_s_u_b_s_t_r_i_n_g Must be of type character.
_b_a_c_k Must be of type logical. If omitted, a value of false is
assumed. If present, the search begins at the end of
_s_t_r_i_n_g.
IINNDDEEXX is an elemental function. The name of this intrinsic can be
passed as an argument.
NNOOTTEESS
When the IINNDDEEXX intrinsic function is passed as an actual argument, it
must be called with only the first two arguments in the routine that
calls the passed-in function.
RREETTUURRNN VVAALLUUEESS
The _b_a_c_k argument can affect the return value as follows:
* If _b_a_c_k is absent or is present with the value FFAALLSSEE, the IINNDDEEXX
search is relative to the left end of _s_t_r_i_n_g. The result is the
minimum positive value of _i, as follows:
_s_t_r_i_n_g (( _i :: _i ++ LLEENN(( _s_u_b_s_t_r_i_n_g )) -- 11 )) == _s_u_b_s_t_r_i_n_g
If the length of _s_u_b_s_t_r_i_n_g is 0, a value of 1 is returned.
* If _b_a_c_k is present with the value TTRRUUEE, the IINNDDEEXX search is relative
to the right end of _s_t_r_i_n_g. The result is the maximum positive
value of the following:
_i <<== LLEENN(( _s_t_r_i_n_g )) -- LLEENN(( _s_u_b_s_t_r_i_n_g )) ++ 11
In the preceding equation, _s_u_b_s_t_r_i_n_g is as follows:
_s_t_r_i_n_g (( _i :: _i ++ LLEENN(( _s_u_b_s_t_r_i_n_g )) -- 11 )) == _s_u_b_s_t_r_i_n_g
If the length of _s_u_b_s_t_r_i_n_g is 0, the value returned is as follows:
LLEENN(( _s_t_r_i_n_g )) ++ 11.
If _s_u_b_s_t_r_i_n_g occurs more than once in _s_t_r_i_n_g, IINNDDEEXX returns the index
to the first occurrence.
The return value is 0 if _s_u_b_s_t_r_i_n_g is not located within _s_t_r_i_n_g.
The return value is 0 if the length of _s_t_r_i_n_g is less than the length
of _s_u_b_s_t_r_i_n_g.
EEXXAAMMPPLLEESS
Example 1: IINNDDEEXX((''FFOORRTTRRAANN'',,''RR'')) has the value 3.
Example 2: IINNDDEEXX((''FFOORRTTRRAANN'',,''RR'',,BBAACCKK==..TTRRUUEE..)) has the value 5.
Example 3: The following program returns the index II==1111 for the
substring SSUUPPEERRCCOOMMPPUUTTEERR:
PROGRAM INDEX1
CHARACTER*23 A
CHARACTER*13 B
A = 'CRAY T90 SUPERCOMPUTER'
B = 'SUPERCOMPUTER'
I = INDEX(A,B)
PRINT *, I
STOP
END
SSEEEE AALLSSOO
_I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
printed version of this man page.